/**
 * 商品相关接口
 */
import request from '@/utils/request'

/**
 * @description 获取商品详情
 * @param {String} id - 商品ID
 * @return Promise
 */
export const findGoods = id => {
  return request('/goods', 'get', { id })
}

/**
 * @description 获取商品同类推荐-未传入ID为猜喜欢
 * @param {String} id 商品id
 * @param {Number} limit 数量限制
 * @return Promise
 */
export const findRelGoods = (id, limit = 16) => {
  return request('/goods/relevant', 'get', { id, limit })
}

/**
 * @description: 获取热榜商品
 * @param {String} id  id-商品id
 * @param {Number} type type-1代表24小时热销榜 2代表周热销榜 3代表总热销榜
 * @param {Number} limit limit-数量限制
 * @return Promise
 */
export const findHotGoods = ({ id, type, limit = 3 }) => {
  return request('/goods/hot', 'get', { id, type, limit })
}

/**
 * @description 获取商品的评价统计信息
 * @param {String} id
 * @return Promise
 */
export const findGoodsCommentInfo = id => {
  return request(`https://mock.boxuegu.com/mock/1175/goods/${id}/evaluate`, 'get')
}

/**
 * @description 获取商品评价列表
 * @param {String} id 商品id
 * @param {*} params 参数
 * @return Promise
 */
export const findGoodsCommentList = (id, params) => {
  return request(`https://mock.boxuegu.com/mock/1175/goods/${id}/evaluate/page`, 'get', params)
}

/**
 * 获取商品的specs和skus
 * @param {String} skuId - 商品SKUID
 * @returns Promise
 */
export const getSpecsAndSkus = skuId => {
  return request(`/goods/sku/${skuId}`, 'get')
}